//
//  HFOLTabBarController.m
//  HFOuLiao
//
//  Created by haifeng on 16/7/5.
//  Copyright © 2016年 sangziwangluo. All rights reserved.
//

#import "HFOLTabBarController.h"
#import "HFOLOuTuiViewController.h"
#import "HFOLDisoveryViewController.h"
#import "HFOLCallViewController.h"
#import "HFOLMessageViewController.h"
#import "HFMineViewController.h"

@interface HFOLTabBarController ()

@property(nonatomic ,strong) HFOLOuTuiViewController *OuTuiVc;
@property(nonatomic, strong) HFOLDisoveryViewController *discoverView;
@property(nonatomic ,strong) HFOLCallViewController *callView;
@property(nonatomic ,strong) HFOLMessageViewController *messageView;
@property(nonatomic ,strong) HFMineViewController *mineView;

@end

@implementation HFOLTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma 事件监听
- (void)clickSearchButton{
    NSLog(@"点击了搜索按钮");
}

- (void)setUpUI{
        //   创建子控制器
    _OuTuiVc = ({
        HFOLOuTuiViewController *OuTuiVc = [[HFOLOuTuiViewController alloc] init];
        OuTuiVc.view.backgroundColor = [UIColor whiteColor];
        // 　设置nav
        UILabel *label = [[UILabel alloc] init];
        label.text = @"偶推";
        [label sizeToFit];
        [label setFont:[UIFont systemFontOfSize:20]];
        OuTuiVc.navigationItem.titleView = label;
        UIImage *image =  [[UIImage imageNamed:@"message_search"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UIBarButtonItem *searchButton = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStyleDone target:self action:@selector(clickSearchButton)];
        OuTuiVc.navigationItem.rightBarButtonItem = searchButton;
        OuTuiVc;
    });
    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:_OuTuiVc];
    [self addChildViewController:nav1];
    
    _discoverView = ({
     HFOLDisoveryViewController *discoverView =[[HFOLDisoveryViewController alloc] init];
    discoverView.view.backgroundColor = [UIColor blueColor];
        UILabel *label = [[UILabel alloc] init];
        label.text = @"发现";
        [label sizeToFit];
        [label setFont:[UIFont systemFontOfSize:20]];
        discoverView.navigationItem.titleView = label;
    discoverView;
    });
    UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:_discoverView];
    [self addChildViewController:nav2];
    
    _callView = ({
        HFOLCallViewController *callView =[[HFOLCallViewController alloc] init];
        callView.view.backgroundColor = [UIColor greenColor];
        UILabel *label = [[UILabel alloc] init];
        label.text = @"通话";
        [label sizeToFit];
        [label setFont:[UIFont systemFontOfSize:20]];
        callView.navigationItem.titleView = label;
        callView;
    });
    UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:_callView];
    [self addChildViewController:nav3];
    
    _messageView = ({
        HFOLMessageViewController *messageView =[[HFOLMessageViewController alloc] init];
        messageView.view.backgroundColor = [UIColor purpleColor];
        UILabel *label = [[UILabel alloc] init];
        label.text = @"消息";
        [label sizeToFit];
        [label setFont:[UIFont systemFontOfSize:20]];
        messageView.navigationItem.titleView = label;
        messageView;
    });
    UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:_messageView];
    [self addChildViewController:nav4];
    
    _mineView = ({
        HFMineViewController *mineView =[[HFMineViewController alloc] init];
        mineView.view.backgroundColor = [UIColor yellowColor];
        UILabel *label = [[UILabel alloc] init];
        label.text = @"我";
        [label sizeToFit];
        [label setFont:[UIFont systemFontOfSize:20]];
        mineView.navigationItem.titleView = label;
        mineView;
    });
    UINavigationController *nav5 = [[UINavigationController alloc] initWithRootViewController:_mineView];
    [self addChildViewController:nav5];
    
    self.viewControllers = @[nav1,nav2,nav3,nav4,nav5];
    
    // Do any additional setup after loading the view.
}

@end
